﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data.Mapping {
    public partial class CartMap : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Cart> {
        public CartMap() {
            ToTable("mc_Cart", "dbo");

            HasKey(t => t.Id);
            Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
          
            Property(t => t.MerchantId)
                .HasColumnName("MerchantId")
                .IsRequired();
            Property(t => t.ProductId)
                .HasColumnName("ProductId")
                .IsRequired();
            Property(t => t.SkuId)
                .HasColumnName("SkuId")
                .IsOptional();
            Property(t => t.ShopId)
                 .HasColumnName("ShopId")
                 .IsOptional();

            Property(t => t.Quantity)
                .HasColumnName("Quantity")
                .IsRequired();
          
          
     


            // Relationships
            HasRequired(t => t.User)
                .WithMany()
                .HasForeignKey(d => d.MerchantId)
                .WillCascadeOnDelete(false);
            HasOptional(t => t.ProductSku)
                .WithMany()
                .HasForeignKey(d => d.SkuId)
                .WillCascadeOnDelete(false);
            HasRequired(t => t.Product)
                .WithMany()
                .HasForeignKey(d => d.ProductId)
                .WillCascadeOnDelete(false);
            HasOptional(t => t.ShopInfo)
             .WithMany()
             .HasForeignKey(d => d.ShopId)
             .WillCascadeOnDelete(false);


        }
    }
}
